package sys.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sys.core.annotation.LoginRequired;
import sys.core.annotation.RecordLog;
import sys.entity.MenuEntity;
import sys.entity.PageData;
import sys.entity.RoleEntity;
import sys.entity.RoleEntity;
import sys.entity.vo.Menu;
import sys.service.RoleService;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/role")
@Api(tags = "角色管理")
public class RoleController {




    @Autowired
    private RoleService roleService;


    /**
     * 查询
     *
     * @return
     */
    @ApiOperation(value = "查询")
   // //@LoginRequired
    @RecordLog
    @PostMapping(value = "/select")
    public RoleEntity select(@RequestBody RoleEntity roleEntity) {
        List<RoleEntity> role = roleService.select(roleEntity);
        return role.get(0);
    }
    @PostMapping(value = "/selectAll")
    public List<RoleEntity> selectAll() {
        return roleService.select(null);
    }


    /**X
     * 模糊查询
     *
     * @returnW
     */
    @ApiOperation(value = "模糊查询")
   // //@LoginRequired
    @RecordLog
    @PostMapping(value = "/likeSelect")
    public PageData<RoleEntity> likeSelect(@RequestBody RoleEntity roleEntity) {
        return roleService.likeSelect(roleEntity);
    }
    /**
     * 更新
     *
     * @return
     */
    @ApiOperation(value = "更新")
    //@LoginRequired
    @RecordLog
    @PostMapping(value = "/update")
    public void update(@RequestBody RoleEntity entity) {
        roleService.update(entity);
    }

    /**
     * 添加
     *
     * @return
     */
    @ApiOperation(value = "添加")
    //@LoginRequired
    @RecordLog
    @PostMapping(value = "/add")
    public void add(@RequestBody RoleEntity entity) {
        roleService.add(entity);
    }

    /**
     * 删除
     *
     * @return
     */
    @ApiOperation(value = "删除")
    //@LoginRequired
    @RecordLog
    @PostMapping(value = "/delete")
    public void delete(@RequestBody RoleEntity entity) {
        roleService.delete(entity);
    }

    /**
     * 导出excel
     *
     * @return
     */
    @ApiOperation(value = "导出excel")
    //@LoginRequired
    @RecordLog
    @GetMapping("/exportExcel")
    public void exportExcel(RoleEntity entity, HttpServletResponse response) {
        roleService.exportExcel(entity, response);
    }

}
